package distanceTraveled;

public class Solution {
    public int distanceTraveled(int mainTank, int additionalTank) {
        int res=0;
        int i = 0;
        while(mainTank>0){
            if(i==5){
                i=0;
                if(additionalTank>0){
                    additionalTank--;
                    mainTank++;
                }
            }
            mainTank--;
            res++;
            i++;
        }
        return res;
    }
}
